package com.xiaotu.storage;

import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.common.util.SepratorUtil;
import com.xiaotu.storage.converter.AConverter;
import com.xiaotu.storage.converter.ConverterFactory;
import com.xiaotu.storage.model.CacheDataModel;

import net.sf.json.JSONObject;

import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * IQY网大受众转储实现类
 */
@Component("IQYNetMovieIndexStorageProcessor")
public class IQYNetMovieIndexStorageProcessor extends MaoYanMoviePeopleStorageProcessor
{

	
	private static final String[] CONVERT_ARR = new String[]{
			AConverter.STRING_CONVERT,
    		AConverter.STRING_CONVERT,
    		AConverter.STRING_CONVERT,
    		AConverter.STRING_CONVERT,
            AConverter.STRING_CONVERT, 
            AConverter.STRINGARRAY_CONVERT, 
            AConverter.NUMBERARRAY_CONVERT, 
            AConverter.STRINGARRAY_CONVERT, 
            AConverter.NUMBERARRAY_CONVERT,
            AConverter.STRINGARRAY_CONVERT, 
            AConverter.NUMBERARRAY_CONVERT, 
            AConverter.STRINGARRAY_CONVERT, 
            AConverter.NUMBERARRAY_CONVERT, 
            AConverter.STRINGARRAY_CONVERT,
            AConverter.NUMBERARRAY_CONVERT, 
            AConverter.STRINGARRAY_CONVERT, 
            AConverter.NUMBERARRAY_CONVERT, 
            AConverter.TIMESTAMP_CONVERT};
	
	@Override
    public String process(JSONObject target, CacheDataModel cacheData,
            Date date)
    {
        return this.list2CSVLine(ConverterFactory.convert(target, FIELD_ARR, CONVERT_ARR,
                THROW_ARR), SepratorUtil.SEP_PIPE);
    }
	
	
    @Override
    protected String getRedisKey(Date date)
    {
        return DataRedisKeyUtils.getKey(Constants.DataRedisKey.IQY_NETMOVIE_INDEX_YYYYMMDD, date);
    }

}
